package com.fei.springfilter.config;

import com.fei.springfilter.me.MyFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;

/***
 * @Date: 2019/9/30 12:30
 * @author: 8非
 * Description: 第二种方法注册MyFilter
 */
//@Configuration
public class FilterConfig {
    @Bean
    public FilterRegistrationBean myFilter(){
        FilterRegistrationBean filterBean = new FilterRegistrationBean();
        MyFilter myFilter = new MyFilter();
        filterBean.setFilter(myFilter);

        ArrayList<String> urlList = new ArrayList<>();
        urlList.add("/test/*");
        urlList.add("/user/*");
        filterBean.setUrlPatterns(urlList);


        return filterBean;
    }
}
